<template>
    <div>
        <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="() => { $router.push('/login/a1') }" />
        <van-search v-model="caches" shape="round" placeholder="请输入搜索关键词" />
        <van-cell-group v-for="item in qsearch">
            <van-cell :title="item.goods_name" />
        </van-cell-group>
        <div style="float: left;">
            <h4>历史搜索</h4>
            <p style="width: 50px;height: 25px;background-color: red;float: left;margin: 15px;">电视剧</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">液晶电视</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">液晶屏幕</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">智能手机</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">苹果手机</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">华为手机</p>
        </div>
        <div style="float: left;">
            <h4>热门搜索</h4>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">手机电池</p>
            <p style="width: 40px;height: 25px;background-color: red;float: left;margin: 15px;">MP3</p>
            <p style="width: 50px;height: 25px;background-color: red;float: left;margin: 15px;">摄像机</p>
            <p style="width: 70px;height: 25px;background-color: red;float: left;margin: 15px;">液晶电视</p>
            <p style="width: 50px;height: 25px;background-color: red;float: left;margin: 15px;">录音笔</p>
            <p style="width: 50px;height: 25px;background-color: red;float: left;margin: 15px;">电脑桌</p>
            <p style="width: 40px;height: 25px;background-color: red;float: left;margin: 15px;">衣柜</p>
            <p style="width: 50px;height: 25px;background-color: red;float: left;margin: 15px;">双人床</p>
        </div>
    </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import { qsearchApi } from '@/api/api'
let qsearch = ref([])
let caches = ref('')
watch(caches, (val) => {
    console.log('监听的数据', val)
    qsearchApi(val).then(res => {
        console.log('搜索', res)
        qsearch.value = res.data.message
    })
})

</script>

<style lang="scss" scoped></style>